package cn.sirun.com.fca.account.repo.modify;

import com.tencent.cloud.iov.kernel.constant.ApiConst;
import com.tencent.cloud.iov.kernel.model.BaseResponse;
import com.tencent.cloud.iov.kernel.service.ServiceGenerator;

import cn.sirun.com.fca.account.model.base.SubmitPasswordRequest;
import cn.sirun.com.fca.account.model.login.AuthenticateRequest;
import cn.sirun.com.fca.account.model.login.AuthenticateResponse;
import cn.sirun.com.fca.account.model.login.ChallengeRequest;
import cn.sirun.com.fca.account.model.login.ChallengeResponse;
import cn.sirun.com.fca.account.repo.login.LoginRepository;
import cn.sirun.com.fca.account.repo.login.LoginService;
import io.reactivex.Observable;

public class ModifyPassRepository {
    private static volatile ModifyPassRepository sInstance;

    public static ModifyPassRepository getInstance() {
        if (sInstance == null) {
            synchronized (LoginRepository.class) {
                if (sInstance == null) {
                    sInstance = new ModifyPassRepository();
                }
            }
        }

        return sInstance;
    }

    private final ModifyPassService mPassService;

    private ModifyPassRepository() {
        mPassService = ServiceGenerator.createService(ModifyPassService.class, ApiConst.getBaseUrl());
    }

    public Observable<BaseResponse<ChallengeResponse>> getChallenge() {
        return mPassService.challenge();
    }

    public Observable<BaseResponse<AuthenticateResponse>> authenticate(
            AuthenticateRequest request) {
        return mPassService.authenticate(request);
    }

    public Observable<BaseResponse<ChallengeResponse>> getSetParams() {
        return mPassService.getSetParams();
    }

    public Observable<BaseResponse<Void>> setPassword(String password) {
        return mPassService.setPassword(new SubmitPasswordRequest(password));
    }

    public Observable<BaseResponse<ChallengeResponse>> changeGetChallenge() {
        return mPassService.changeGetChallenge();
    }

    public Observable<BaseResponse<AuthenticateResponse>> changeAuthenticate(
            AuthenticateRequest request) {
        return mPassService.changeAuthenticate(request);
    }

}
